home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Amiga Collections: Panorama
/
Panorama - Disk 28C (1988-04-27)(Pacific North-West Amigas Club)[WB].zip
/
Panorama - Disk 28C (1988-04-27)(Pacific North-West Amigas Club)[WB].adf
/
ModulaII
/
Etchm2
/
EtchGlobal.Mod
< prev
next >
Wrap
Text File
|
1987-12-24
|
2KB
|
68 lines
IMPLEMENTATION MODULE EtchGlobal;
(*********************************************************)
(* Some low level routines for EtchAsketch *)
(* *)
(* Written for the Benchmark M2 compiler. *)
(* *)
(* Steve Faiwiszewski December 1987 *)
(*********************************************************)
FROM Memory IMPORT MemReqSet, MemPublic, MemChip,
MemClear;
FROM Intuition IMPORT FreeRemember, AllocRemember;
FROM TermInOut IMPORT WriteString, WriteLn;
FROM RunTimeErrors
IMPORT InstallErrorHandler,
RemoveErrorHandler;
FROM SYSTEM IMPORT ADDRESS;
VAR
CurrentTermProc : CARDINAL;
TermProcs : ARRAY [0..50] OF PROC;
PROCEDURE TheEnd;
BEGIN
WriteString('Releasing all allocations.'); WriteLn;
FreeRemember(RKey, TRUE);
RemoveErrorHandler;
HALT
END TheEnd;
PROCEDURE Allocate(VAR ptr : ADDRESS; size : LONGCARD);
BEGIN
ptr := AllocRemember(RKey, size,
MemReqSet{MemClear,MemPublic});
END Allocate;
PROCEDURE ChipAllocate(VAR ptr : ADDRESS; size : LONGCARD);
BEGIN
ptr := AllocRemember(RKey, size,
MemReqSet{MemClear,MemPublic,MemChip});
END ChipAllocate;
PROCEDURE AddTerminationProc(t : PROC);
(* Insert procedure t into the array of terminating *)
(* procedures (which are called upon graceful exit. *)
BEGIN
TermProcs[CurrentTermProc] := t;
INC(CurrentTermProc)
END AddTerminationProc;
PROCEDURE ExitGracefully;
(* Call all the designated terminating procedures. *)
VAR
i : CARDINAL;
BEGIN
FOR i := (CurrentTermProc-1) TO 0 BY -1 DO
TermProcs[i]
END
END ExitGracefully;
BEGIN
RKey := NIL;
CurrentTermProc := 0;
AddTerminationProc(TheEnd);
(* The error handler is installed just in case we need it. *)
InstallErrorHandler;
END EtchGlobal.